#include"logger.h"
#include"reactor.h"

 Reactor::Reactor()
 {
   reactor_ = event_base_new();
   if(!reactor_)
   {
    LOG_ERROR <<"event_base_new() failed!";
   }
 }
 Reactor::~Reactor()
 {
    
 }
 void Reactor::AddEventAndHander(int fd,short int events ,event_callback_fun callback,void * arg)
 {
    struct event * ev = event_new(reactor_,fd,events,callback,arg);
    if(!ev)
    {
        LOG_ERROR <<"event_new() failed";
    }
    if(-1 == event_add(ev,NULL))
    {
        LOG_ERROR <<"event_add() failed";
    }
 }
 void Reactor::Loop()
 {
   event_base_dispatch(reactor_);
 }